package com.weather.androidweather;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.weather.androidweather.adapter.ForecastDetailAdapter;
import com.weather.androidweather.model.DayForecast;
import java.util.ArrayList;

public class ForecastDetailActivity extends AppCompatActivity {
    private RecyclerView forecastRecyclerView;
    private ForecastDetailAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.forecast_detail_activity);

        // 初始化视图
        initViews();
        
        // 获取传递的数据
        ArrayList<DayForecast> forecasts = getIntent().getParcelableArrayListExtra("forecasts");
        if (forecasts != null) {
            adapter.setForecasts(forecasts);
        }
    }

    private void initViews() {
        // 设置返回按钮
        ImageButton backButton = findViewById(R.id.backButton);
        backButton.setOnClickListener(v -> finish());

        // 设置RecyclerView
        forecastRecyclerView = findViewById(R.id.forecastRecyclerView);
        forecastRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        adapter = new ForecastDetailAdapter();
        forecastRecyclerView.setAdapter(adapter);
    }
} 